Page({
  data: {
    loading: true,
    active: 0,
    url0: 'https://mp.weixin.qq.com/mp/appmsgalbum?__biz=MzI3OTM2NDY2NA==&action=getalbum&album_id=1503588811639980033&f=json&count=10',
    url1: 'https://mp.weixin.qq.com/mp/appmsgalbum?__biz=MzI3OTM2NDY2NA==&action=getalbum&album_id=1576173070623539201&f=json&count=10'
  },
  onLoad(options) {
    if (options.mode == 1) {
      this.getList(this.data.url1)
    } else {
      this.getList(this.data.url0)
      this.setData({
        active: 0
      })
    }
  },
  getList(url) {
    var that = this
    that.setData({
      loading: true
    })
    wx.request({
      url: url,
      header: {
        'content-type': 'application/json' // 默认值
      },
      success(res) {
        console.log(res.data.getalbum_resp.article_list)
        that.setData({
          list: res.data.getalbum_resp.article_list
        })
        that.setData({
          loading: false
        })
      }
    })
  },
  onChange(event) {
    console.log(event.detail)
    this.setData({
      active: event.detail
    })
    if (this.data.active == 0) {
      this.getList(this.data.url0)
      this.setData({
        active: 0
      })
    } else if (this.data.active == 1) {
      this.getList(this.data.url1)
      this.setData({
        active: 1
      })
    }
  },
  goDetail(e) {
    wx.navigateTo({
      url: '/pages/webView/webView?url=' + encodeURIComponent(e.currentTarget.dataset.url)
    })
  },
  onShareAppMessage: function (res) {
    return {
      title: 'TLradio',
      path: '/pages/article/article?mode=0',
      imageUrl: '../../images/share1.png'
    }
  },
  onShareTimeline: function () {
    return {
      title: 'TLradio - 文章列表',
      query: 'from=pyq&mode=0'
    }
  }
})